﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CarLoanSystem.Entity;

namespace CarLoanSystem
{
    public partial class frmDebtInfoDetail : Form
    {
        private static DeptDetailItem deptDetailItem;
        private static int deptId;
        public frmDebtInfoDetail(int id)
        {
            InitializeComponent();
            deptId = id;
        }

        public frmDebtInfoDetail(int deptDetailId, int id)
        {
            InitializeComponent();
            this.txtDetail.Enabled = false;
            this.btnSave.Visible = false;
            deptDetailItem = DAL.DeptDetailInfoDAL.LoadDeptDetail(deptDetailId);
            this.txtDetail.Text = deptDetailItem.DEBT_DETAIL;
            this.dtpDate.Value = deptDetailItem.DEBT_DETAIL_DATE;
            deptId = id;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            deptDetailItem = new DeptDetailItem();
            deptDetailItem.DEBT_DETAIL = this.txtDetail.Text;
            deptDetailItem.DEBT_DETAIL_DATE = dtpDate.Value;
            deptDetailItem.DEBT_ID = deptId;
            DAL.DeptDetailInfoDAL.Insert(deptDetailItem);
            MessageBox.Show("บันทึกข้อมูลสำเร็จ", "รายละเอียดการติดต่อ");
            this.Close();
        }

        private void btnCancal_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
